package com.burgeon.backend.SHOPBACKEND.rest;

import com.burgeon.backend.Rest.base.RESTBase;
import org.json.JSONArray;
import org.springframework.util.MultiValueMap;

import java.util.HashMap;

/**
 * 修改C_VIP开卡人
 */
public class ModVipLogo extends RESTBase {

    private String ip;
    private String account;
    private String password;

    public ModVipLogo(String ip, String account, String password) {
        this.ip = ip;
        this.account = account;
        this.password = password;
    }

    /**
     * 发送并接收字符创
     */

    public String getData(String id, String logo) throws Exception {
        String url = "http://" + ip + "/servlets/binserv/Rest";
        String str = RESULT(Data(id,logo), url);
       // System.err.println(str);
        String code = new JSONArray(str).getJSONObject(0).getString("code");
        String message= new JSONArray(str).getJSONObject(0).getString("message");
        if (!"0".equals(code)) {

            throw new Exception(message);

        }
        return code;
    }
    private MultiValueMap Data(String id, String logo) {

        HashMap params = new HashMap();

        params.put("ID", id);
        params.put("partial_update","true");

        params.put("table", "C_VIP");//表名

        params.put("LOGO_URL", "'"+logo+"'");//UNREAD


        return DATA("ObjectModify", params,account,password);
    }

    public static void main(String[] args) {//
        ModVipLogo g = new ModVipLogo("59.110.28.94:90", "nea@burgeon.com.cn", "burgeon55321");
        try {

            g.getData("260671", "263");
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
